package com.oocl.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.oocl.dao.DishTypeDao;
import com.oocl.pojo.Dish;
import com.oocl.pojo.DishType;
import com.oocl.util.DBUtil;

public class DishTypeDaoImpl implements DishTypeDao {

	@Override
	public List<DishType> getAllDishTypes() {
		List<DishType> dtl = new ArrayList<DishType>();
		String sql="select * from dishtype";
		PreparedStatement pst =null;
		ResultSet rs = null;
		Connection conn = null;
		DishType dt =null;
		int n =0;
		try {
			conn=DBUtil.getConnection();
			pst=conn.prepareStatement(sql);
			rs=pst.executeQuery();
			while(rs.next()){
				dt=new DishType();
				dt.setDishTypeNum(rs.getInt("dtypenum"));
				dt.setDishTypeName(rs.getString("dtypename"));
				dtl.add(dt);
			}
			n=pst.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally{
			DBUtil.release(rs, pst, conn);
		}
		return dtl;
	}



}
